from scipy.io import loadmat
import output_function as of
import numpy as np
import matplotlib.pyplot as plt

# 假设你的 .mat 文件名为 'dat0001.mat'，并且位于当前目录下

filename = './data/dat8800.mat'

# 使用 loadmat 函数读取 .mat 文件
data = loadmat(filename)

# 直接访问变量
wi = data['wi']
phii = data['phii']
T0i = data['T0i']
Ti = data['Ti']
vex = data['vex']
vey = data['vey']

init_data=loadmat('./data/initial.mat')
alx = init_data['alx'][0][0]
aly = init_data['aly'][0][0]
dt=init_data['dt'][0][0]
#meshgrid
xx=init_data['x']
yy=init_data['y']
Ra=init_data['Ra']
out_iter=8800

print(xx)

#of.diag_n_pcolor_filepath(Ti.T, vex.T, vey.T, xx.T, yy.T, out_iter, Ra, dt)
of.diag_n_pcolor_filepath(Ti,   vey,vex, yy,xx, out_iter, Ra, dt)
# 如果需要，转置xx和yy以匹配正确的维度
# if np.all(xx[0, :] == xx[0, 0]) and np.all(yy[:, 0] != yy[0, 0]):  # 检查是否需要转置
#     xx = xx.T
#     yy = yy.T

# 绘制热力图
# plt.figure(figsize=(10, 6))
# heatmap = plt.pcolormesh( yy,xx, Ti, shading='auto', cmap='viridis')  # cmap 可以更换为你喜欢的颜色映射
# plt.colorbar(heatmap, label='Value')  # 添加颜色条，标签可以根据实际情况替换
# plt.xlabel('X-axis')
# plt.ylabel('Y-axis')
# plt.title('Heatmap of T values')
# plt.show()